import 'package:flutter/material.dart';
// import 'package:camera/camera.dart';
import 'package:path/path.dart';
import 'package:path_provider/path_provider.dart';
import 'dart:async';
import 'dart:io';
import '../../main.dart';


class Test21 extends StatefulWidget{
    
    _TestState createState() => _TestState();
}

class _TestState extends State<Test21> {

    // CameraController controller;
    // Future  _initializeControllerFuture;
    
    @override
    void initState() {
        // cameraInit();
        super.initState();
        
    }

    void cameraInit()async{
        // controller = CameraController(cameras.first, ResolutionPreset.max);
        // _initializeControllerFuture = controller.initialize();
    }

    @override
    void dispose() {
        // controller.dispose();
        super.dispose();
    }

    @override
    Widget build(BuildContext context) {
        return Scaffold(
            // floatingActionButton: FloatingActionButton(
            //     child: Icon(Icons.camera_alt),
            //     onPressed: () async {
            //         try {
            //             final path = join((await getTemporaryDirectory()).path, '${DateTime.now()}.png');
            //             await controller.takePicture(path);
            //             Navigator.push(
            //                 context,
            //                 MaterialPageRoute(
            //                     builder: (context) => DisplayPictureScreen(imagePath: path),
            //                 ),
            //             );
            //         } catch (e) {
            //             print(e);
            //         }
            //     },
            // ),
            appBar: AppBar(
                title: Text("相机"),
            ),
            // body: Column(
            //     children: <Widget>[
            //         Container(
            //             constraints: BoxConstraints(
            //                 maxHeight: 500
            //             ),
            //             child: FutureBuilder<void>(
            //                 future: _initializeControllerFuture,
            //                 builder: (context, snapshot) {
            //                     print(snapshot.connectionState);
            //                     if (snapshot.connectionState == ConnectionState.done) {
            //                         return AspectRatio(
            //                             aspectRatio: controller.value.aspectRatio,
            //                             child: CameraPreview(controller),
            //                         );
            //                     } else {
            //                         return Center(child: CircularProgressIndicator());
            //                     }
            //                 },
            //             ),
            //         )
            //     ],
            // )
            
        );
    }



}




class DisplayPictureScreen extends StatelessWidget {
  final String imagePath;
 
  const DisplayPictureScreen({Key key, this.imagePath}) : super(key: key);
 
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text('Display the Picture')),
      body: Image.file(File(imagePath)),
    );
  }
}